/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "hhdICollisionObject.h"

#include "btBulletCollisionCommon.h"
#include "btBulletDynamicsCommon.h"

#include "hhdRegistry.h"

namespace hhd
{
	namespace BulletPhysics
	{
		class HogsheadMotionState;
		class BulletPhysicsDirector;

		/**
		A TriggerVolumes does not interact with other RigidBodies or TriggerVolumes, but collisions are detected.
		It is assumed there is only one RigidBody or one TriggerVolume component on a single GameObject.  On collision 
		with another RigidBody or TriggerVolume, a CollisionMessage will be sent with a list of contat points.
		@see RigidBodyType
		**/

		class TriggerVolume : public ICollisionObject
		{
			CollisionObjectH(hhd::BulletPhysics::TriggerVolume, TriggerVolume);
			HHD_REGISTRANT_H(IComponent, TriggerVolume);

		public:
			TriggerVolume();
			void initialize();
			IComponent* readXML(const String& in_xml);
			void update(const GameTimer&);
		private:
			btCollisionObject* _collision_object;
			btCollisionShape* _collision_shape;
			// activation methods
			void onSetActive();
			void onSetInactive();
			// pointer to the director
			BulletPhysicsDirector* _bullet_director;

			static void handle_set_group_mask(IMessageReceiver* me, IMessage* msg);
			static void handle_set_activity(IMessageReceiver* me, IMessage* msg);

			int _previous_mask;
		};
	}
}
